package com.tjetc.service.impl;

import com.tjetc.common.JsonResult;
import com.tjetc.common.vo.user.ALL;
import com.tjetc.dao.CityMapper;
import com.tjetc.dao.HomeMapper;
import com.tjetc.dao.SpotMapper;
import com.tjetc.dao.TravelogueMapper;
import com.tjetc.entity.*;
import com.tjetc.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class HomeServiceImpl implements HomeService {
    @Autowired
    HomeMapper homeMapper;
    @Autowired
    CityMapper cityMapper;
    @Autowired
    TravelogueMapper travelogueMapper;
    @Autowired
    SpotMapper spotMapper;
    @Override
    public JsonResult getHomeShow() {
        List<Home> homes =new ArrayList<>();
        homes=homeMapper.selectHomeShow();
        return JsonResult.success("成功查询到首页",homes);
    }

    @Override
    public JsonResult getDestinations(Integer l) {
         List<City>cities=new ArrayList<>();
         cities=cityMapper.hotcity(l);
        return JsonResult.success("成功查询到热门城市",cities);
    }

    @Override
    public JsonResult getTravelogues(Integer l) {

        List<Travelogue> travelogues=travelogueMapper.getTop(l);
        return JsonResult.success("成功查询到热门游记",travelogues);
    }

    @Override
    public JsonResult getGuides(Integer l) {
        return null;
    }

    @Override
    public JsonResult search(String s) {
        List<City> cities = cityMapper.searchCity(s);
        List<Spot> spots = spotMapper.searchSpot(s);
        List<Travelogue> travelogues = travelogueMapper.searchTravelogue(s);
//        List<Guide> guides = guideMapper.searchGuide(s);

//        ALL all = new ALL(cities, spots, travelogues, guides);
        return JsonResult.success(null);
    }
}
